package com.example.hzz.criminalintent;

import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

/**
 * Created by huangzezhan on 2018/8/23.
 */

public abstract class SingleFragmentActivity extends FragmentActivity {
    private Fragment fragment;

    protected abstract Fragment CreateFragment();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_crime);

        FragmentManager fm = getFragmentManager();
        fragment = fm.findFragmentById(R.id.crime_fragment_id);
        if (fragment == null) {
            fragment = CreateFragment();
            fm.beginTransaction()
                    .add(R.id.crime_fragment_id,fragment)
                    .commit();
        }

    }
}
